<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SCDL - 生存战争下载中心</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        :root {
            --primary: #42b983;
            --secondary: #4fc08d;
            --text-primary: #333;
            --text-secondary: #666;
            --bg-primary: #ffffff;
            --bg-secondary: #f8f9fa;
            --border-color: #e0e0e0;
            --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s ease;
        }

        .dark-theme {
            --text-primary: #f0f0f0;
            --text-secondary: #a9d6e5;
            --bg-primary: #1a1a2e;
            --bg-secondary: #252540;
            --border-color: #333355;
            --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
            transition: var(--transition);
        }

        body {
            background-color: var(--bg-primary);
            color: var(--text-primary);
            min-height: 100vh;
            padding: 20px;
            display: flex;
            flex-direction: column;
        }

        .container {
            width: 100%;
            max-width: 100%;
            margin: 0 auto;
            flex: 1;
            display: flex;
            flex-direction: column;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 1px solid var(--border-color);
            width: 100%;
        }

        .logo {
            font-size: 1.8rem;
            font-weight: bold;
            color: var(--primary);
            white-space: nowrap;
        }

        .nav-controls {
            display: flex;
            gap: 15px;
        }

        .theme-toggle {
            display: flex;
            align-items: center;
            padding: 8px 15px;
            background: var(--bg-secondary);
            border-radius: 30px;
            border: 1px solid var(--border-color);
            cursor: pointer;
            color: var(--text-primary);
            white-space: nowrap;
        }

        .theme-toggle:hover {
            background: rgba(67, 97, 238, 0.1);
        }

        .theme-toggle i {
            margin-right: 8px;
        }

        .filter-section {
            margin-bottom: 20px;
            width: 100%;
        }

        .filter-toggle {
            display: flex;
            align-items: center;
            padding: 10px 15px;
            background: var(--bg-secondary);
            border-radius: 8px;
            cursor: pointer;
            border: 1px solid var(--border-color);
            margin-bottom: 10px;
            width: 极速下载中心
        }

        .filter-toggle i {
            margin-right: 8px;
        }

        .filter-panel {
            display: none;
            background: var(--bg-secondary);
            border-radius: 8px;
            padding: 15px;
            border: 1px solid var(--border-color);
            margin-bottom: 20px;
            max-height: 300px;
            overflow-y: auto;
            width: 100%;
        }

        .filter-panel.active {
            display: block;
        }

        .filter-group {
            margin-bottom: 15px;
            width: 100%;
        }

        .filter-title {
            font-size: 1rem;
            margin-bottom: 10px;
            color: var(--text-primary);
            font-weight: 600;
        }

        .platform-selector, .api-selector {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
            gap: 10px;
            width: 100%;
        }

        .platform-option, .api-option {
            padding: 10px;
            border-radius: 8px;
            cursor: pointer;
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            text-align: center;
            min-width: 120px;
        }

        .platform-option.active, .api-option.active {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
        }

        .platform-info {
            font-size: 0.8rem;
            color: var(--text-secondary);
            margin-top: 5px;
        }

        .version-list {
            background: var(--bg-secondary);
            border-radius: 8px;
            overflow: hidden;
            border: 1极速下载中心
            flex: 1;
            display: flex;
            flex-direction: column;
            width: 100%;
        }

        .version-header {
            display: grid;
            grid-template-columns: 2fr 1fr 1fr 1fr;
            padding: 15px 20px;
            background: rgba(38, 38, 70, 0.1);
            font-weight: bold;
            border-bottom: 1px solid var(--border-color);
            width: 100%;
        }

        .version-content {
            flex: 1;
            overflow-y: auto;
            width: 100%;
        }

        .version-row {
            display: grid;
            grid-template-columns: 2fr 1fr 1fr 1fr;
            padding: 15px 20px;
            border-bottom: 1px solid var(--border-color);
            width: 100%;
        }

        .version-row:hover {
            background: rgba(58, 12, 163, 0.05);
        }

        .version-info {
            display: flex;
            flex-direction: column;
            min-width: 0; /* 防止内容溢出 */
        }

        .version-id {
            font-weight: bold;
            font-size: 1.1rem;
            margin-bottom: 4px;
            color: var(--primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .version-tag {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 0.8rem;
            font-weight: bold;
            background: rgba(76, 201, 240, 0.2);
            color: #4cc9f0;
            margin-top: 5px;
            white-space: nowrap;
        }

        .version-desc {
            font-weight: bold;
            color: var(--text-primary);
            margin-top: 10px;
            grid-column: 1 / -1;
            word-break: break-word;
        }

        .version-date, .download-count {
            display: flex;
            align-items: center;
            color: var(--text-secondary);
            white-space: nowrap;
        }

        .action-buttons {
            display: flex;
            justify-content: flex-end;
            align-items: center;
            min-width: 0; /* 防止内容溢出 */
        }

        .btn-download {
            padding: 8px 15px;
            border-radius: 30px;
            border: none;
            background: var(--primary);
            color: white;
            font-weight: bold;
            cursor: pointer;
            display: flex;
            align-items: center;
            white-space: nowrap;
        }

        .btn-download:hover {
            background: var(--secondary);
            transform: translateY(-2px);
        }

        .btn-download i {
            margin-right: 8px;
        }

        .footer {
            text-align: center;
            margin-top: auto;
            padding-top: 25px;
            border-top: 1px solid var(--border-color);
            color: var(--text-secondary);
            font-size: 0.9rem;
            width: 100%;
        }

        .loading-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        .loading-content {
            background: var(--bg-secondary);
            border-radius: 12px;
            padding: 30px;
            text-align: center;
            max-width: 400px;
            width: 90%;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
        }

        .loading-spinner {
            width: 60px;
            height: 60px;
            border: 5px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top-color: var(--primary);
            animation: spin 1s ease-in-out infinite;
            margin: 0 auto 20px;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        .loading-text {
            font-size: 1.2rem;
            color: var(--text-primary);
            margin-bottom: 10px;
        }

        .error-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        .error-content {
            background: var(--bg-secondary);
            border-radius: 12px;
            padding: 30px;
            text-align: center;
            max-width: 400px;
            width: 90%;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
        }

        .error-icon {
            font-size: 3rem;
            color: #ff6b6b;
            margin-bottom: 20px;
        }

        .error-text {
            font-size: 1.2rem;
            color: var(--text-primary);
            margin-bottom: 20px;
        }

        .retry-btn {
            padding: 10px 25px;
            border-radius: 30px;
            border: none;
            background: var(--primary);
            color: white;
            font-weight: bold;
            cursor: pointer;
        }

        /* 响应式调整 */
        @media (max-width: 1200px) {
            .version-header, .version-row {
                grid-template-columns: 1.5fr 1fr 1fr 1fr;
            }
        }

        @media (max-width: 992px) {
            .version-header, .version-row {
                grid-template-columns: 1.2fr 1fr 1fr 1fr;
            }
            
            .version-id {
                font-size: 1rem;
            }
        }

        @media (max-width: 768px) {
            .header {
                flex-direction: column;
                gap: 15px;
                text-align: center;
            }
            
            .version-header, .version-row {
                grid-template-columns: 1fr;
                gap: 10px;
            }
            
            .action-buttons {
                justify-content: center;
                margin-top: 10px;
            }
            
            .version-id {
                font-size: 1.1rem;
            }
            
            .btn-download {
                width: 100%;
                justify-content: center;
            }
        }

        @media (max-width: 576px) {
            body {
                padding: 10px;
            }
            
            .logo {
                font-size: 1.5rem;
            }
            
            .theme-toggle {
                padding: 6px 12px;
                font-size: 0.9rem;
            }
            
            .filter-toggle {
                padding: 8px 12px;
            }
            
            .platform-selector, .api-selector {
                grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
            }
            
            .platform-option, .api-option {
                min-width: 100px;
                padding: 8px;
            }
            
            .version-header, .version-row {
                padding: 10px 15px;
            }
        }

        @media (max-width: 480px) {
            .platform-selector, .api-selector {
                grid-template-columns: 1fr;
            }
            
            .version-id {
                font-size: 1rem;
            }
            
            .btn-download {
                padding: 6px 12px;
                font-size: 0.9rem;
            }
        }
    </style>
</head>
<body>
    <div class="loading-modal" id="loadingModal">
        <div class="loading-content">
            <div class="loading-spinner"></div>
            <div class="loading-text">正在加载数据，请稍候...</div>
        </div>
    </div>

    <div class="error-modal" id="errorModal" style="display: none;">
        <div class="error-content">
            <div class="error-icon">
                <i class="fas fa-exclamation-triangle"></i>
            </div>
            <div class="error-text">呜呜呜,数据离开了我们。过会再回来看看吧。</div>
            <button class="retry-btn" id="retryBtn">重试</button>
        </div>
    </div>

    <div class="container" id="mainContent" style="display: none;">
        <div class="header">
            <div class="logo">SCDL</div>
            <div class="nav-controls">
                <div class="theme-toggle" id="themeToggle">
                    <i class="fas fa-adjust"></i>
                    <span id="themeText">主题设置</span>
                </div>
            </div>
        </div>
        
        <div class="filter-section">
            <div class="filter-toggle" id="filterToggle">
                <i class="fas fa-filter"></i>
                <span>筛选选项</span>
            </div>
            
            <div class="filter-panel" id="filterPanel">
                <div class="filter-group">
                    <div class="filter-title">平台选择</div>
                    <div class="platform-selector" id="platformSelector">
                        <div class="platform-option active" data-platform="windows">
                            Windows
                            <div class="platform-info">适用于PC电脑</div>
                        </div>
                        <div class="platform-option" data-platform="android">
                            Android
                            <div class="platform-info">适用于安卓设备</div>
                        </div>
                    </div>
                </div>
                
                <div class="filter-group">
                    <div class="filter-title">API版本</div>
                    <div class="api-selector" id="apiSelector">
                        <div class="api-option active">API 1.20</div>
                        <div class="api-option">API 1.19</div>
                        <div class="api-option">API 1.18</div>
                        <div class="api-option">API 1.17</div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="version-list" id="versionList">
            <div class="version-header">
                <div>版本信息</div>
                <div>更新日期</div>
                <div>下载量</div>
                <div>操作</div>
            </div>
            <div class="version-content" id="versionContent">
                <!-- 版本行将通过JS动态生成 -->
            </div>
        </div>
        
        <div class="footer">
            <p>© 2025 SCDL 版权所有</p>
            <p>本站资源均来自网络搜索或社区集合,如有错误请联系QQ:1757027442</p>
        </div>
    </div>
    
    <script>
        // 主题管理功能
        const themeToggle = document.getElementById('themeToggle');
        let currentTheme = localStorage.getItem('theme') || 'auto';
        
        // 应用主题
        function applyTheme(theme) {
            document.body.classList.remove('dark-theme');
            
            if (theme === 'dark' || (theme === 'auto' && isNightTime())) {
                document.body.classList.add('dark-theme');
            }
            
            // 更新按钮文本
            const themeText = document.getElementById('themeText');
            if (themeText) {
                const themes = {
                    'light': '亮色主题',
                    'dark': '暗色主题',
                    'auto': '自动主题'
                };
                themeText.textContent = themes[theme];
            }
            
            // 保存主题设置
            localStorage.setItem('theme', theme);
            currentTheme = theme;
        }
        
        // 检查是否是夜间
        function isNightTime() {
            const hour = new Date().getHours();
            return hour < 6 || hour >= 18;
        }
        
        // 主题切换按钮点击事件
        themeToggle.addEventListener('click', function() {
            const themes = ['light', 'dark', 'auto'];
            const currentIndex = themes.indexOf(currentTheme);
            const nextIndex = (currentIndex + 1) % themes.length;
            applyTheme(themes[nextIndex]);
        });
        
        // 筛选面板切换
        const filterToggle = document.getElementById('filterToggle');
        const filterPanel = document.getElementById('filterPanel');
        
        filterToggle.addEventListener('click', function() {
            filterPanel.classList.toggle('active');
        });
        
        // 加载弹窗和错误弹窗元素
        const loadingModal = document.getElementById('loadingModal');
        const errorModal = document.getElementById('errorModal');
        const retryBtn = document.getElementById('retryBtn');
        const mainContent = document.getElementById('mainContent');
        const versionContent = document.getElementById('versionContent');
        
        // 模拟数据
        const mockData = {
            platforms: [
                { id: "windows", name: "Windows", desc: "适用于PC电脑" },
                { id: "android", name: "Android", desc: "适用于安卓设备" }
            ],
            apiVersions: ["API 1.20", "API 1.19", "API 1.18", "API 1.17"],
            versions: [
                {
                    id: "1.21.94",
                    name: "正式版 1.21.94",
                    isLatest: true,
                    date: "2025-07-14",
                    downloads: 22789,
                    desc: "此版本修复了多个漏洞，优化了游戏性能，与1.21.93版本完全兼容。",
                    platforms: ["windows", "android"],
                    apiVersions: ["API 1.20"],
                    downloadUrl: "https://example.com/download/1.21.94"
                },
                {
                    id: "1.21.93",
                    name: "1.21.93",
                    isLatest: false,
                    date: "2025-07-03",
                    downloads: 15146,
                    desc: "添加了新的生物群落和物品，改进了多人游戏体验。",
                    platforms: ["windows", "android"],
                    apiVersions: ["API 1.20", "API 极速下载中心
                    downloadUrl: "https://example.com/download/1.21.93"
                },
                {
                    id: "1.21.92",
                    name: "1.21.92",
                    isLatest: false,
                    date: "2025-06-19",
                    downloads: 10823,
                    desc: "优化了图形渲染性能，修复了内存泄漏问题。",
                    platforms: ["windows", "android"],
                    apiVersions: ["API 1.20", "API 1.19"],
                    downloadUrl: "https://example.com/download/1.21.92"
                },
                {
                    id: "1.21.90",
                    name: "1.21.90",
                    isLatest: false,
                    date: "2025-06-17",
                    downloads: 2933,
                    desc: "实验性版本，包含即将推出的新功能和内容，仅供测试使用。",
                    platforms: ["windows"],
                    apiVersions: ["API 1.20"],
                    downloadUrl: "https://example.com/download/1.21.90"
                }
            ]
        };
        
        // 获取数据
        function fetchData() {
            // 模拟网络请求延迟
            setTimeout(() => {
                try {
                    processData(mockData);
                } catch (error) {
                    console.error('处理数据失败:', error);
                    showError();
                }
            }, 1500);
        }
        
        // 处理数据
        function processData(data) {
            try {
                // 验证数据格式
                if (!Array.isArray(data.versions) || !Array.isArray(data.platforms)) {
                    throw new Error('无效的数据格式');
                }
                
                // 渲染平台选择器
                renderPlatforms(data.platforms);
                
                // 渲染API版本选择器
                renderApiVersions(data.apiVersions);
                
                // 渲染版本列表
                renderVersions(data.versions);
                
                // 显示主内容
                loadingModal.style.display = 'none';
                mainContent.style.display = 'block';
            } catch (error) {
                console.error('处理数据失败:', error);
                showError();
            }
        }
        
        // 渲染平台选择器
        function renderPlatforms(platforms) {
            const platformSelector = document.getElementById('platformSelector');
            platformSelector.innerHTML = '';
            
            platforms.forEach(platform => {
                const platformOption = document.createElement('div');
                platformOption.className = 'platform-option';
                platformOption.dataset.platform = platform.id;
                platformOption.innerHTML = `
                    ${platform.name}
                    <div class="platform-info">${platform.desc}</div>
                `;
                
                platformOption.addEventListener('click', function() {
                    document.querySelectorAll('.platform-option').forEach(opt => {
                        opt.classList.remove('active');
                    });
                    this.classList.add('active');
                    filterVersions();
                });
                
                platformSelector.appendChild(platformOption);
            });
            
            // 默认选择第一个平台
            if (platformSelector.firstChild) {
                platformSelector.firstChild.classList.add('active');
            }
        }
        
        // 渲染API版本选择器
        function renderApiVersions(apiVersions) {
            const apiSelector = document.getElementById('apiSelector');
            apiSelector.innerHTML = '';
            
            apiVersions.forEach(api => {
                const apiOption = document.createElement('div');
                apiOption.className = 'api-option';
                apiOption.textContent = api;
                
                apiOption.addEventListener('click', function() {
                    document.querySelectorAll('.api-option').forEach(opt => {
                        opt.classList.remove('active');
                    });
                    this.classList.add('active');
                    filterVersions();
                });
                
                apiSelector.appendChild(apiOption);
            });
            
            // 默认选择第一个API版本
            if (apiSelector.firstChild) {
                apiSelector.firstChild.classList.add('active');
            }
        }
        
        // 渲染版本列表
        function renderVersions(versions) {
            versionContent.innerHTML = '';
            
            versions.forEach(version => {
                const versionRow = document.createElement('div');
                versionRow.className = 'version-row';
                
                versionRow.innerHTML = `
                    <div class="version-info">
                        <div class="version-id">${version.name}</div>
                        ${version.isLatest ? '<div class="version-tag">最新版本</div>' : ''}
                    </div>
                    <div class="version-date">${version.date}</div>
                    <div class="download-count">${version.downloads.toLocaleString()}</div>
                    <div class="action-buttons">
                        <button class="btn-download" data-url="${version.downloadUrl}">
                            <i class="fas fa-download"></i> 下载
                        </button>
                    </div>
                    <div class="version-desc">
                        ${version.desc}
                    </div>
                `;
                
                versionContent.appendChild(versionRow);
            });
            
            // 添加下载按钮事件
            document.querySelectorAll('.btn-download').forEach(btn => {
                btn.addEventListener('click', function() {
                    const url = this.dataset.url;
                    alert(`开始下载: ${url}`);
                });
            });
        }
        
        // 筛选版本
        function filterVersions() {
            // 实际应用中根据选择筛选版本
            // 这里简化处理，直接显示所有版本
        }
        
        // 显示错误
        function showError() {
            loadingModal.style.display = 'none';
            errorModal.style.display = 'flex';
        }
        
        // 重试按钮
        retryBtn.addEventListener('click', function() {
            errorModal.style.display = 'none';
            loadingModal.style.display = 'flex';
            fetchData();
        });
        
        // 初始化
        function init() {
            // 确保DOM完全加载后再应用主题
            applyTheme(currentTheme);
            fetchData();
        }
        
        // 页面加载完成后初始化
        window.addEventListener('DOMContentLoaded', init);
    </script>
</body>
</html>
